package com.example.personalizededucationsystem.dto.dto;

import com.example.personalizededucationsystem.model.Question;
import com.example.personalizededucationsystem.model.StudentAssignmentAnswer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class StudentAnswerDetailDto {
    private Long questionId;
    private String content;
    private String type;
    private String correctAnswer;
    private String userAnswer;
    private Boolean isCorrect;

    public static StudentAnswerDetailDto from(StudentAssignmentAnswer answer) {
        Question q = answer.getQuestion();
        return new StudentAnswerDetailDto(
                q.getQuestionId(),
                q.getContent(),
                q.getType().name(),
                q.getAnswer(),
                answer.getUserAnswer(),
                answer.getIsCorrect()
        );
    }
}

